package cn.dengta.webapp.im.enums;

import javax.annotation.Nullable;

import lombok.Getter;
import org.apache.commons.lang3.EnumUtils;

/**
 * 消息类型
 */
@Getter
public enum YunxinMsgType {

	TEXT(0, "文本消息", true),
	PICTURE(1, "图片消息", true),
	AUDIO(2, "语音消息", true),
	VIDEO(3, "视频消息"),
	LOCATION(4, "地理位置"),
	NOTIFICATION(5, "通知"),
	FILE(6, "文件消息"),
	TIPS(10, "提示类型消息"),
	CUSTOM(100, "自定义消息", true);

	public final Integer value;
	final String desc;
	final boolean costRequired;

	YunxinMsgType(Integer value, String desc, boolean costRequired) {
		this.value = value;
		this.desc = desc;
		this.costRequired = costRequired;
	}

	YunxinMsgType(Integer value, String desc) {
		this(value, desc, false);
	}

	public static boolean needPayment(@Nullable String type) {
		YunxinMsgType msgType = EnumUtils.getEnum(YunxinMsgType.class, type, null);
		return msgType != null && msgType.costRequired;
	}

}
